//index.js
//获取应用实例
var dsq, dsq1,a = getApp()

Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },bindGetUserInfo: function(t) {
        console.log(t), "getUserInfo:ok" == t.detail.errMsg && (this.setData({
            hydl: 1
        }), this.changeData());
    },
    changeData: function() {
        var n = this;
        wx.getSetting({
            success: function(t) {
                console.log(t), t.authSetting["scope.userInfo"] ? wx.getUserInfo({
                    success: function(t) {
                        console.log(t), a.util.request({
                            url: "entry/wxapp/login",
                            cachetime: "0",
                            data: {
                                openid: getApp().getOpenId,
                                headimgurl: t.userInfo.avatarUrl,
                                nickname: t.userInfo.nickName
                            },
                            header: {
                                "content-type": "application/json"
                            },
                            dataType: "json",
                            success: function(t) {
                                console.log("用户信息", t);
                            }
                        });
                        var e = t.userInfo;
                        console.log(e), n.setData({
                            userInfo: t.userInfo,
                            hasUserInfo:true
                        });
                    }
                }) : (console.log("未授权过"), n.setData({
                    hydl: 0
                }));
            }
        });
    },
  onLoad: function (e) {
    var o = this;
    var n = decodeURIComponent(e.scene);
    if (console.log("scene", n), "undefined" != n) var t = n;
    if (null != e.userid) {
      console.log("转发获取到的userid:", e.userid);
      t = e.userid;
    }
    console.log("fxzuid", t), this.setData({
      fxzuid: t
    }),a.getUserInfo(function (e) {
      console.log(e), null != t ? a.util.request({
        url: "entry/wxapp/Binding",
        cachetime: "0",
        data: {
          fx_user: e.id,
          user_id: t
        },
        success: function (e) {
          console.log(e);
        }
      }) : a.util.request({
        url: "entry/wxapp/Binding",
        cachetime: "0",
        data: {
          fx_user: e.id,
          user_id: 0
        },
        success: function (e) {
          console.log(e);
        }
      });
      var u = a.globalData.userInfo;
      if(u.nicname){
        o.setData({
          userInfo: a.globalData.userInfo
        });
      }
     
    }), a.util.request({
      url: "entry/wxapp/system",
      cachetime: "0",
      success: function (e) {
        var n = Number(e.data.countdown);
        dsq = setInterval(function () {
          n-- , o.setData({
            second: n
          });
        }, 1e3);
        var t = e.data;
        o.setData({
          xtxx: t,
          second: e.data.countdown
        }), getApp().xtxx1 = t;
      }
    });
   
  },

})
